package com.xindacloud.sms.portal.service.impl;

import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xindacloud.sms.portal.dao.SmsApiMapper;
import com.xindacloud.sms.portal.dao.SmsApiReqParamMapper;
import com.xindacloud.sms.portal.dao.SmsApiResParamMapper;
import com.xindacloud.sms.portal.dto.ResSmsApiDTO;
import com.xindacloud.sms.portal.dto.SmsApiDTO;
import com.xindacloud.sms.portal.entity.SmsApi;
import com.xindacloud.sms.portal.entity.SmsApiReqParam;
import com.xindacloud.sms.portal.entity.SmsApiResParam;
import com.xindacloud.sms.portal.service.ISmsApiService;

/**
 * <p>
 * 系统主菜单表 服务实现类
 * </p>
 *
 * @author czc
 * @since 2019-10-08
 */
@Service
public class SmsApiServiceImpl extends ServiceImpl<SmsApiMapper, SmsApi> implements ISmsApiService {

	@Autowired
	private SmsApiReqParamMapper reqMapper;
	
	@Autowired
	private SmsApiResParamMapper resMapper;
	
	@Override
	public Object getSmsApiList(SmsApiDTO smsApiDTO) {
		
		QueryWrapper<SmsApi> queryWrapper=new QueryWrapper<>();
		if(smsApiDTO.getCategoryId()!=null) {
			queryWrapper.eq("category_id", smsApiDTO.getCategoryId());
		}
		SmsApi smsApi=this.getOne(queryWrapper);
		ResSmsApiDTO resSmsApiDTO=new ResSmsApiDTO();
		if(smsApi!=null) {
			QueryWrapper<SmsApiReqParam> reqQuery=new QueryWrapper<>();
			QueryWrapper<SmsApiResParam> resQuery=new QueryWrapper<>();
			reqQuery.eq("api_id", smsApi.getId());
			resQuery.eq("api_id", smsApi.getId());
			List<SmsApiReqParam> reqList=reqMapper.selectList(reqQuery);
			List<SmsApiResParam> resList=resMapper.selectList(resQuery);
			BeanUtils.copyProperties(smsApi, resSmsApiDTO);
			resSmsApiDTO.setReqList(reqList);
			resSmsApiDTO.setResList(resList);
		}
		
		return resSmsApiDTO;
	}


	

}
